<?php
function outLog($a,$b){
    if($b==0){
        echo "[".time()." $a] success\n";
    }else{
        echo "[".time()." $a] failed\n";
        exit($b);
    }
}
function getOS(): string
{
    $a=php_uname("s");
    for ($i=65;$i<=90;$i++){
        if (is_dir(chr($i).":\\Windows")){
            return "Windows";
        }
    }
    return"Linux";
}
function run($a,$b){
    exec("$a $b",$c,$d);
    if ($d==1){
        echo $b."\n";
        echo json_encode($c)."\n";
    }
    outLog($a,$d);
}
if (getOS()=="Windows"){
    $start_time=time();
    if (is_dir("build")) {
        run("rd", "/s /q build");
    }
    if (is_dir("split")) {
        run("rd", "/s /q split");
    }
    echo "Finished in ".(time()-$start_time)."s";
}